<?php
namespace App\Components;

/**
 * Class WizardStep
 */
class WizardStep{
	
	/** @var String $id */
	private $id = '';
	
	/** @var String $title */
	private $title = '';
	
	/** @var String $info */
	private $info = '';
	
	/** @var Form $form */
	private $form = null;
	
	/** @var array $dependency - how this step change other steps!!!*/
	private $dependency = array();
	
	public function __construct($id, $title, $info, $form = null, $dependency = array()){
		$this->id = $id;
		$this->title = $title;
		$this->info = $info;
		$this->form = $form;
		$this->dependency = $dependency;
	}
	
	/**
	 * destroy cache session 
	 */
	public function destroyCache(){
		if(isset($_SESSION[$this->id])){
			unset($_SESSION[$this->id]);
		}
		return $this;
	}
	
	/**
	 * Returns session cache
	 * 
	 * @return array
	 */
	public function getCache() {
		if(isset($_SESSION[$this->id])){
			return $_SESSION[$this->id];
		}else{
			return array();
		}
	}
	
	/**
	 * Set session cache
	 * 
	 * @param array $cache
	 * @return \App\Components\WizardStep
	 */
	public function setCache($cache) {
		$_SESSION[$this->id] = $cache;
		return $this;
	}
	
	public function getId() {
		return $this->id;
	}
	
	public function getTitle() {
		return $this->title;
	}

	public function getInfo() {
		return $this->info;
	}

	public function getForm() {
		return $this->form;
	}
	
	public function getDependency(){
		return $this->dependency;
	}
	
	public function getInitialShow() {
		return $this->initialShow;
	}
	
	public function setId($id) {
		$this->id = $id;
		return $this; 
	}

	public function setTitle($title) {
		$this->title = $title;
		return $this; 
	}

	public function setInfo($info) {
		$this->info = $info;
		return $this;
	}

	public function setForm($form) {
		$this->form = $form;
		return $this;
	}
	
	public function setDependency($dependency) {
		$this->dependency = $dependency;
		return $this;
	}

}
